package com.model.dome1;

import com.model.domin.Student;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashMapDemo1 {
    public static void main(String[] args) {
//        HashMap<String,String> map=new HashMap<>();
        HashMap<Student, String> map=new HashMap<>();

        Student s1 = new Student("林青霞", 30);
        Student s2 = new Student("张曼玉", 35);
        Student s3 = new Student("王祖贤", 33);
        Student s4 = new Student("王祖贤", 33);

        map.put(s1,"西安");
        map.put(s2,"北京");
        map.put(s3,"南京");
        map.put(s4,"长沙");

        Set<Map.Entry<Student, String>> entries = map.entrySet();

        for (Map.Entry<Student, String> entry : entries) {
            Student key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+value);
        }

        System.out.println("========================");

        map.forEach(
                (Student key,String value)->{
                    System.out.println(key+value);
                }
        );
    }
}
